package com.atguigu.lock;

import java.util.concurrent.locks.ReentrantLock;

public class Ticket {
    private int number = 100;

    private ReentrantLock lock = new ReentrantLock();

    public void sale(){
        lock.lock();
        try {
            if (number > 0){
                number--;
                System.out.println(Thread.currentThread().getName()+"剩余："+number);
            }
        }finally {
            lock.unlock();
        }

    }
}
